make fit for python3

dict.iteritems() does not exist in python3, and the performance hit with items() should not exist with python3 and be marginally with python2

also basestring does not exist with python3, but we can instead check against str. Since we want to do this only in python3, its only used as fallback if basestring raises a nameerror
add a global check for python3
Merge pull request #4 from duesenfranz/master

Add python3 compatibility