[FIX] Fix issues by flake8 on Python 3

Some scripts were still using Python 2 specific code which is now
removed. If possible they were rewritten to support both versions
without extra conditions.

Unfortunately flake8 doesn't detect that certain code is never run in
Python 3. Those lines are just marked with '# noqa' to ignore them
(unfortunately it's not possible to # noqa them just for Python 3).

Change-Id: Ie1e676056ffce9fdabc203442f4b86a88013fe6f
Merge "[FIX] Fix issues by flake8 on Python 3"