Fix some Python 3.x code errors according to issue #145