Semi-automatic conversion to Python 3