Win32 fixes

A bunch of minor fixes found running the tests across Python versions on 32-bit Python for Windows.  Once these pass Travis, assuming they do, I'll tag 0.4rc1.