Misc py3 compatibility fixes.