Write plots in a BLOB instead of a temporary file which simplifies the code a
bit and improves performance.