tests: write to unique images
py3k compatibility in gen_settings.py - refs #165