I'm terribly sorry. I have just solved my problem - I should stop getting up at such early hours :) The problem was in the flow of execution in the script, basically after printing the content of binary files to STDOUT, the script kept going and printed some unrelated data as well.