Fixed endian conversion
Added linux compatability