Is simply saving to disk and providing the relative path in the HTML code an option? You can use QImage::save() to write to disk.
EDIT: If you want to load directly from the buffer you can use QImage directly into HTML images: https://qt-project.org/doc/qt-4.8/qtwebkit-bridge.html#pixmaps-and-images.