fixed endianness detection (thanks to Toad King)