Changed img.py to use Python 3-compatible dictionary iterators.