Well, if you're on a Windows system, and you use a non-binary-safe function on binary data, it will probably go read a 0x10 byte and go "Duuuh, \n. New line. Duuuh, okay, new line" and replace it with two bytes 0x13 0x10 for Windows' brain-dead idea of having "\r\n" to indicate the ends of lines. Your binary data is now garbage.
For safety, don't use binary-unsafe functions to read or write binary data (specific details depend on the specific function in question). And/or use a Unix-based OS.