Various style and build fixes.

### Changelog
* Fixed most `pylint` warnings.
* Suppressing `distutils` import error. The outstanding error in Travis will be fixed once #900 is merged.
* Suppressing `py2exe` import error, as is installed by configure script.
* Suppressing `py2exe` unused import error; this is the standard way to use it.
* Moved setup code inside a `main` function.