PY3: use six.iterkeys, six.iteritems, and tempfile

This one is less trivial.

I was looking to change Headers.iteritems too, but that one seems different in behavior, so I left alone everything related to that.
IMHO there is no harm in using items() here. But iteritems is also fine :)