2. JPEG also allows for comments and other embedded metadata which won't show up in the displayed image.
3. Start the file with a JPEG header and metadata section, then switch between HTML and JPEG using the comment functionality mentioned above
Essentially!
"But wait, why is it shown as an image in one context and as a web page in another?"
The answer is in the question: Context. If you expect a JPEG you will get a JPEG, and same for HTML.