Have into account endianess

Pointed by @mandreko, have into account endianess, more work needs to be done here, pr coming from @mandreko soon, just a temporal fix.