output image to browser and capture the content with buffer