Update Python syntax in contrib/ to Python 3.