add flake8 setup and fix really bad style

This PR puts the coding style in setup.cfg, such that we can run flake8 against the codebase.

The PR also fixes really poor style (wrong indents, double spaces after keywords, etc).