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.