flake8 and Python 3 compatibility tweaks.