Fixed errors arising from Python 3.x