Fix some issues in Python 3