Use ->getImageAsString() to save an image as a response content and do some logic to set proper response content-type header.