Instead of base64 encoding all images we could potentially use void QTextDocument::addResource(int type, const QUrl &name, const QVariant &resource) to insert the binary image. For the browser case we'd likely have to do the same via url scheme handler using a custom url scheme.
Purely a potential optimization.