Fix flake8

ran "autopep8 --in-place --aggressive" on each file + manual fixes
Merge pull request #2040 from jgmize/fix-flake8

Fix flake8