Fixing compatibility issues while converting to Python 3.