Fix python3 compatibility

This includes fixes related to the use of strings/bytes as well
dict.iteritems().
Merge pull request #54 from larsbutler/fix-py3-compatibility

Fix Python 3 compatibility