Loop over the database fetching image data