Fix minor compatibility issue with dict.keys()

The way the return of the keys method of dictionaries was used was
invalid python 3.4, which was now changed and is valid for both 3.4 and
2.7.