Fix some Python 3.x issues that have slipped in.

Since I initially did our 3.x porting, a few things have slipped in (mostly
merges from the 1.7.x branch, which doesn't have the same requirements).

Testing done:
Ran 2to3 and saw that the only reported issues are expected (presence of
__future__ stuff, and code where we use six to update something but 2to3 can't
tell the difference).

Reviewed at https://reviews.reviewboard.org/r/6327/