Minor tweaks/updates

I've had these changes sitting in my fork for a while, and I may as well make a pull request. None of these changes are very important, and I'd understand if you reject this to avoid unnecessary code churn.

* The <code>md5</code> fallback import isn't necessary anymore since all supported versions of Python ship with the <code>hashlib</code> module.
* I missed a few occurrences of iterating over e.g. <code>dict.items()</code> in the first pull request -- again, may as well skip the intermediate list if the return value is used purely for iteration.
* For membership testing, a <code>set</code> is a bit more direct than using a <code>dict</code> that maps each element to <code>None</code>.
* The <code>__future__.print_function</code> usage makes the code (more or less) valid syntax in both Python 2 and 3. These changes were all produced by <code>2to3</code>; making these changes up-front reduces the work done by <code>2to3</code> in <code>setup.py build</code> and makes it easier to edit the code in an IDE that's configured for Python 3.