On the matplotlib page for savefig it says:
savefig(fname, …
Parameters
fname str or path-like or binary file-like
A path, or a Python file-like object.
A file-like-object is one which supports the .read() and .write() interface.
Suggesting one could put together an object which somehow uses IOBuffer rather than files.