Fix compatibility to Python 3