Python3 compatibility fixes.