Fixed TypeError exceptions occuring with python3.