Fix various Python 2.x->3.x compat issues

Fix current git's Hacking H23x warnings via
mechanical translation to avoid the easy
Python 3.x compatibility issues.

Change-Id: Ic94ef537b0722c8b65fc3fecc093dc0cb25673cc