Python 3 fixes

All tests pass, as far as I can tell. I only see failures related to my local memcached server misbehaving, but the module seems to handle this. Everything but to the doctests change works in Python 2.6+ and 3.2+.

I'm not sure of a good way to have doctests that work in both versions; lots of the text output differs between versions.