Fix Python 3 compatibility

Replaced `iterkeys()` with `keys()`, since it seems to be the easiest fix for Python 3 compatibility. I don't think the memory footprint of such a list would anyway be significant performance-wise.