Fix bug where SVG output would sometimes have extra </g> tag

When generating SVG images, if there is no "\</g>\<g data-header" present in svgData by line 501 to replace, the resulting SVG file encounters errors because of the unconditionally added "\</g>" tag:

![image](https://f.cloud.github.com/assets/2461496/1043861/0c045c42-1007-11e3-8b0c-e4e3e559cbb6.png)

This fix adds the "\</g>" tag only if the regex in line 498 finds at least one match (if onHeaderPath is called at least once, which would give line 501 something to replace).

Would it work to leave the the old replace in and put it inside this conditional?  As in replace this block with:
```
if subsMade > 0:
  # Replace the first </g><g> with <g>, and close out the last </g> at the end
  svgData = svgData.replace('</g><g data-header','<g data-header',1) + "</g>"

svgData = svgData.replace(' data-header="true"','')
```