Miscellaneous Python 3 compatibility fixes

This takes care of the "print-function" and "StringIO" Python 3 incompatibilities.

I imagine the "contextlib.nested" ones are going to be pretty annoying, and I have no clue about the "__module__" errors.

(You can run the tests under Python 3 with `$ TOXENV=py34 tox`)
Ah! Thanks