Writing tiff to a memory buffer

Hello,

I’d like to write an image in tiff format to a memory buffer (not a file) so that I can pass it off to a server using libcurl. How do I go about this?

Thanks
Ollie.