Fix endianess for compatibility with javascript ArrayBuffer