insert a matplotlib image in an html image element.

Hello,

My problem is the following : I would like to create an image using the matplolib facilities and then insert this image
in a <IMG SRC="*data*:*image*/???;base64 *.../> *element.
Then using Gecko (mozilla) and python + xpcom, I would try to interact with this image (zoom ...).

In order to succeed I feel I have to understand how a back-end is written.

It seems I have to start with the Figure class.
But then I can't find the image format, the way to return binary data or perhaps base64 data.
I don't want to save the figure in a file et then read it with <IMG SRC="theFile.png"/>.
The speed would be very low.

What is the process to add a new back-end ?

I wish the encode/decode base64 wil not take too much time for keeping the dynamism of gtk back-end (for instance).
What do you think about that ?

Thanks a lot,

Cyril.