I've draw a Japanese flag like shown below and I used toDataURL twice. The first one work fine same as the canvas but the second one appeared with black background and I don't know why??!
canvas = document.getElementById('mycanvas')
context = canvas.getContext('2d')
context.fillStyle= 'red'
canvas.style.border = '1px solid black'
context.beginPath()
context.moveTo(160 , 120)
context.arc(160 , 120 , 70 , 0 , Math.PI *2 , false)
context.closePath()
context.fill()
image = document.getElementById('myimage')
image.style.border = '1px solid black'
image.src = canvas.toDataURL()
image2 = document.getElementById('myimage2')
image2.style.border = '1px solid black'
image2.src = canvas.toDataURL('image/jpeg' , 10)
and this is the result "I used Chrome and FireFox to test this" The result