Zoom and pan problems

I’ve been working on making a photo gallery. I have got it so the thumbnails and images load from an XML file. However, I want to give viewers the option to zoom and pan the image. I’ve made buttons that can be clicked to zoom in 2X and 3x, but I don’t know how to keep the image centered when you zoom or how to make it pan. Any ideas on where to start?