This issue is specific to the Debian version of iText 1.x that was patched to replace the Sun JPEGImageEncoder with ImageIO in order to work with GNU Classpath.
iText started using ImageIO with the version 2.0.5 and the ByteArrayOutputStream was properly wrapped with ImageIO.createImageOutputStream(baos) (which results in the creation of a MemoryCacheImageOutputStream). The current version of iText 2.x packaged in Debian is no longer affected by this issue.
smime.p7s
Description: Signature cryptographique S/MIME