changed .next() to next(imageIdGeneratior) as <generator>.next() is renamed to __next__() in Python 3.x