cleaner svg output (namespace only once and only in the outer element)

The svg string created varies between browsers and had many unnecessary namespace definitions in. This change builds the svg itself and does not use innerHTML. The output is more cleaner and the namespaces are only defined in the outer element.

It is a little slower then the old solution, around 1.1 to 1.5 times. But in some tests with chrome it was faster?