I've not done any gimp-perl, but I've used GIMP quite a bit. The only thing that comes to mind is that you may need to flatten the whole
$img before saving. If the script provides new layers and masks, and you're asking to save it (in the GUI), you'd be told that you must export and flatten it to a single layer entity before saving to JPEG format. Perhaps in the script, you're just saving the back layer of the results, which would be the original image without the effect of the extra layers and masks.
--
[ e d @ h a l l e y . c c ]