Generate the image in RAM - cStringIO - and output as inline base64, simplifies the whole thing, no image needed on disc, no munin rewrite interference