having trouble with strange bytes inserted into otherwise correct output files