I don't like your code
The problem is you don't know where the image ends and the archive starts. You could search for the signature of a zip/rar archive in the image file, but who says those can't occur in the body of an image? Therefore you can't be sure it's actually going to work.
If I were you I'd get the hell rid of that cmd command and start using real Java code and attach some more to that file...
Say this is your current method:
<image (?? bytes)><archive (?? bytes)>
You don't know where the image ends and the archive starts, nor can you distinguish a normal image from an image containing an archive.
What I would do is something like this:
<image (x bytes)><archive (?? bytes)><4 byte integer x><4 byte number>
In this case you'll add 8 byte (which is almost nothing) to the image but you can easily solve your problems. The 4 byte number on the end should be the same for each image, allowing you to distinguish an edited image from a normal one. (Pick a number and add it to each image so you can identify the images.)
The 4 bytes in front of that should represent an integer which contains the size of the image. (Before you packed an archive in it.)
So what you should do is:
Image a (size: x bytes)
Archive b (size: y bytes)
Output f (size: x+y+8 bytes)
Me-code:
f.write(a);
f.write(b);
f.write(a.size());
f.write(0x58);
f.write(0x59);
f.write(0x12);
f.write(0xA2);