Replaced plain StringIO with the one from six.py.
StringIO was moved in python 3.
Fixed mistakenly replaced use of locals().
This locals() wasn't inside a list comprehension and was also replaced
incorrectly.
Merge pull request #1403 from HapeMask/py3k-fixes

Py3k Fixes Bugfixes