I spent some time looking at this today but have to stop. I got as far as determining that the $str variable (which holds the data that's missing in the downloaded file) gets lost somewhere inside the t3lib_cs::conv() method. Specifically in my case, I'm losing it when it gets passed through the iconv() function on line 631 of lib/typo3/class.t3lib_cs.php
This is new territory for me as far as the moodle script and the iconv function. I have a suspicion that this isn't the source of the problem though. If I bypass that function and try to just return the original $str (with its correct value) the script still fails to deliver what I'd expect.
I'll come back to this later this week, but maybe someone else with some more insight will see this in the meantime