Fix endianness error in the binary output write