The cache images plugin: http://blog.milandinic.com/wordpress/plugins/cache-images/ helped me with this, it does not on demand replace the links but rather goes through all links but basically does the same.
One note on this: when I ran it on a small blog it worked pretty well. On another blog (http://edward.de.leau.net) it did a lot of posts but then somewhere in the middle it began replacing ALL images so including the ones that were under http://edward.de.leau.net .... I havent investigated that one I just broke it off. So be careful when you run large batches with this one and keep checking the replace logging screen.
update the new version of the plugin allows on-demand side loading, see: http://weblogtoolscollection.com/archives/2010/11/28/wordpress-plugin-releases-for-1128-2/#comments