Fix a number of byteswapping bugs

I hope this will fix #963.  

I have tested it under qemu ppc emulation with Debian 6 using the system Python 2.6, and `pip`-installed Numpy 1.7.1 (testing Numpy 1.4.1 has too many limitations).