More Python 3 fixes

This includes more fixes for Python 3. It reduces the number of failures, but not to zero. Feel free to merge for now, and I can try and tackle some of the other failures later if you can't get them to pass.