When I was studying image compression back at university we wrote a whole bunch of lossy/lossless codecs. The issue is that most of the cool algorithms are protected by patents (such as Arithmetic coding). JPEG is quite old now and you can achieve much better results with wavelet coding as opposed to the traditional DCT approach. Plus it doesn't suffer the horrible blockiness effect that quantized DCT based stuff does.
Edit: If anybody has a few hours of time to waste here's a thesis I wrote on deblocking JPEG images a long time ago. http://www.csse.monash.edu.au/hons/projects/2005/Mirsad.Maka...