Fixing some Python3 compatibility issues.