Added Python 3 compatibility

Exchanged iteritems() for item() and added helper function for printing