try ULONG instead of BYTE: perhaps ofstream will not try displaying it as ASCII char, this way.