loci: fix byte swapping on OS X

Reviewer: @carlroth
CC @jonstout

The endian.h functions don't exist on OS X, so use the LOCI versions instead.
Also change the byte order macro used to one that's defined on both Linux and OS X.