Fix all PEP-8 warnings

This is a pretty massive patch that resolves all warnings and errors as currently reported by the PEP-8 static analyser. The code after this should be properly working for both python2 and python3 and respect all current upstream coding policies.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>