Use binary.Write to do endian conversion