How to output the image segments in cache to a file!