TheNorm:
What's base64 encoding? Why would anyone do anything in base 64? Is there something I should have read?
Yesss.
Your original question:
Should I be able to serve .jpg files?
... was perhaps a bit vaguely worded. You can send any file you like, but the HTTP transfer protocol is basically text. You can send other things, but they are usually base-64 encoded, which effectively turns them into text.
I suppose we assumed that since you are generating HTML pages you might know that. Ah well.
Basically you run the file (in batches) through the base64-encoder, which makes it 4/3 times larger. I think you usually do the data in batches of around 57 bytes which become 76 bytes when encoded (ie. the length of a line in an email message).
You will also need to look at the header, I think you need to tell the browser that the text is base64-encoded.
Something like this line in addition to what you have:
Content-Transfer-Encoding: base64
An example, from an email I got:
Content-Type: image/png;
name="image001.png"
Content-Transfer-Encoding: base64
Content-ID: <image001.png@01CD20C6.92DC0A80>
iVBORw0KGgoAAAANSUhEUgAAAoAAAAPACAYAAACl4sj7AAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA/45JREFU
eF7sfQWYXdW5dv7/v6XtvXWlSItDaYFCW2rU/daNGhUoUqS4exIsBEhCQoQQd3d318lkfDIT9yBB
Something roughly along those lines. Look it up, there will be lots of references. And you should find a base-64 encoding function easily enough.