When I look in W3Graphics.pas, I see that TCanvas has a ToDataURL function. So you can use this function without the asm section, like
var dataURL := W3Canv.ToDataURL('');
(note: javascript within an asm section is case sensitive!)
You can also take a look at W3Image.pas and it's TW3Image.toDataUrl function