Well, I think most modern browser would recognise the actual file format (independent of the file extension) but I wouldnt really recommend this way.
If you havent tried it yet, I would see whether I can optimise the image down to 256 colors. If it doesnt work you should either really change the template code, alternatively you could also work with a HTTP redirect (redirect all GIF requests to the JPEG version). Although this would be unnecessarily resource intensive it could solve your problem.