This isn't performing well and UUEncoding is proving over fiddly, but let's checkpoint what I've got before I try moving things in a different direction.