I have heard of binary, but nevermessed with em...is this something to look in to???
The binary file mode allows you to directly write to a file at a byte-by-byte level.