I need to convert the canvas tag into a image file and it need to support the IE6+,Mozilla 3+ and saffari 5+
There ain't no way IE6 supports canvas. It's not even supported in IE8...
In Firefox the browser displays the canvas element as an image on the client side, so your user can right click the canvas and use the "save-image" functionality to get the image.
Safari doesn't support this, but it is possible to save the image using javascript as described in this blog post
to use the canvas element in ie < 9 (at least parts of it) you could use the explorercanvas javascript library, but i don't know if it supports saving the content as an element.
another possibility is using svg to render images on the serverside or in an applet using the batik-framework from apache
ExplorerCanvas doesn't allow saving as an image using Javascript, since it's VML and not Canvas. You can get the XML source of a VML image, but you'd still need a back-end script to parse the VML and save it to an image file.
You could also use the fxCanvas library to fake canvas in IE. This library does support toDataURL(), but requires the Flash plugin.
Other browsers and Internet Explorer 9 support canvasElement.toDataURL() natively.