fix potential errors on Python 3