Replaced tabs with spaces and removed usage of several deprecated features:

* dict.has_key -> `in` operator
* backticks -> repr

Also removed trailing newlines from a few files.

flake8 --select='W' no longer reports any issues