Misc fixes in preparation for Python 3

These fixes are relevant in Python 2, and my upcoming port to 3 is based on them.

Please have a close look at the first commit, to _marshall.py_, because I’m not familiar with the protocol. I just guessed it is meant to encode the number of bytes rather than Unicode characters; I haven’t actually seen any errors or test failures etc related to this.

BTW it’s not a huge deal, but I prefer that you don’t include my literal email address in public commits. I try to disguise it on purpose.