The proc in question where the corruption happens is acs_mail_base64_encode in the "ns_uuencode doesn't work" codeblock.
Here's the switch that I tracked things back to:
switch $state {
0 { # OK }
1 { append result $base64_en([expr {(($old << 4) & 0x30)}])== }
2 { append result $base64_en([expr {(($old << 2) & 0x3C)}])= }
}
With jpegs, the encoded string ends with "==", which translates to state being 1 and zips end with state being 2. Word docs on the other hand end with a state of 0 and they are fine.
Any hints greatly appreciated.