Index: /applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/ComputeBoundsAction.java
===================================================================
--- /applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/ComputeBoundsAction.java	(revision 30385)
+++ /applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/ComputeBoundsAction.java	(revision 30386)
@@ -188,5 +188,5 @@
         "        " + simpleTag(XML_NAME, name) + "\n"+
         "        " + simpleTag(XML_TYPE, type, "wms") + "\n"+
-        "        " + simpleTag(XML_URL, url != null ? encodeUrl(url) : "") + "\n"+
+        "        " + simpleTag(XML_URL, url != null ? encodeUrl(url) : "", false) + "\n"+
 	             bounds+"\n";
 		if (projections != null && !projections.isEmpty()) {
@@ -326,12 +326,15 @@
 	protected static final String getClosedWayShape(Way cw) {
 		String result = "            <shape>\n";
-		for (int i=0; i<cw.getNodesCount()-1; i++) {
+		for (int i=0; i<cw.getNodesCount(); i++) {
 			if (i%3 == 0) {
 				result += "                ";
 			}
+			int j = i;
+			if(j == cw.getNodesCount())
+			    j = 0;
 			result += "<point ";
 			result += "lat='" + df.format(cw.getNode(i).getCoor().lat()) + "' ";
 			result += "lon='" + df.format(cw.getNode(i).getCoor().lon()) + "'/>";
-			if (i%3 == 2 || i == cw.getNodesCount()-2 ) {
+			if (i%3 == 2 || i == cw.getNodesCount()-1 ) {
 				result += "\n";
 			}
