Step 4) Figure out if base64-encoded attachments can be decoded in a way that allows re-encoding them back to the exact original encoding. If so, save the attachment decoded and add the necessary encoding info the dbox metadata.
Although you might like to do that for some sort of tidiness or whatever, I don't think there's an actual requirement to restore it to base64 (or q-p or whatever). Those are just transfer encodings, and intermediate MTAs might in theory have transformed them (though in practice that's doubtful). The one use case for an exact reconstruction might be some older digital signature schemes (which were not so robust and probably lost if an intermediate MTA messed with things).
Or perhaps just store them compressed. How much of a difference is there between storing decoded data vs. compressed base64 encoded data?
The best you can ever do is break even, and often you will lose. In any case, you have the CPU/memory cost of the compress/decompress. I would get rid of any transfer encoding and try to compress. If the compression was above some threshold of storage benefit, store it compressed. Otherwise, store it uncompressed.