Fix memory leak when rendering images as HTML

As mentioned here https://github.com/jgm/stmd/pull/66#discussion_r17724553