You have to understand how HTTP works to understand your problem. Consider these points.
-
HTTP uses a stateless request/response pair. One response for one request.
-
Each response has a content-type header which tells the client what type of content is in this response
Given number 2 you should understand your problem. You are talking about a Response with multiple content types. This is not supported by HTTP. If you are still confused and asking yourself, how do typical web pages have images and text content, refer to points 1 and 2 above. When a browser sees, within the text/html content of a response, "<img src='image.jpg' />" it knows to issue another HTTP request for the URL http://..../image.jpg. The server then responds with a new content type (img/jpeg). So your browser issues multiple requests and reads multiple responses.
Long story short. You need either an HTTPHandler (the best practice way) to handle your images, or just a separate .aspx page that is meant to serve images. You have already suceeded in responding with an image, so just move that code to your image.aspx page. Use a query string parameter (or session) to determine which image to send. Then on your original page use an HTML image tag with src="ImagePage.aspx" mce_src="ImagePage.aspx".
Hope this helps.