support multiple pages

There may be more than 16 images for whole gallery. This patch
supports more than one page.