Add compatibility with Python 3