looping over images in chunks