Avoid aliasing problems by using special buf endian handling functions w...

...rapping memcpy