You can base64 encode the image directly in the HTML. That way you do not need to implement additional image file server functionality or create temporary files.
image_stream = open(image_file) # This opens a file, but you can just as well use a in-memory buffer
data = Base64.base64encode(image_stream)
html = """<img src="data:image/png;base64,$(data)">"""