fix the way endianness is detected

I believe the code used to detect endianness is similar to this thread: http://lua-users.org/lists/lua-l/2008-11/msg00075.html.

However, the current code fails to detect the correct endianness on openWRT system on a MIPS cpu (which is big endian)