Fix byte order confusion which broke on big endian platforms