 		/** @inheritDoc */
 		public function write(ds:DataSet, output:IDataOutput=null):IDataOutput 
 		{
+			var sbgnml:XML = new XML(<sbgn/>);
+			var map:XML = new XML(MAP);
+			
 			if (output == null) output = new ByteArray();
 			sbgnml.setNamespace(new Namespace(SBGN_NAMESPACE));
+			
+			//Write back glyphs
+			for each (var sprite:CompoundNodeSprite in (ds.nodes as GraphicsDataTable).dataSprites) 
+			{	
+				map.appendChild((writeGlyph(new XML(), sprite)));
+			}
+	
+			//Write back arcs
+			for each (var edgeSprite:EdgeSprite in (ds.edges as GraphicsDataTable).dataSprites) 
+			{	
+				map.appendChild(arcToXML[edgeSprite.data.id]);
+			}
+			
+			sbgnml.appendChild(map);
+	
 			output.writeUTFBytes(sbgnml.toXMLString());
-			
 			return output;
+		}
+		
+		protected function writeGlyph(glyph:XML, cns:CompoundNodeSprite): XML
+		{	
+			var tempXML:XML = glyphToXML[cns.data.id];
+			var bboxList:XMLList = tempXML.elements("bbox");
+			
+			for each (var bbox:XML in bboxList) 
+			{
+				var glyphBbox:Rectangle = cns.data.glyph_bbox;
+				
+				bbox.@["x"] = cns.x - glyphBbox.width/2;
+				bbox.@["y"] = cns.y - glyphBbox.height/2;
+			}
+			
+			glyph = tempXML;
+			
+			for each (var childSprite:CompoundNodeSprite in cns.getNodes()) 
+			{
+				writeGlyph(glyph, childSprite);
+			}
+			
+			return tempXML;
 		}
 		
 		/**

				}
				
				lookup[cns.data.id] = cns;
			}
			
			// Add Child glyphs

			var glyphSchema:DataSchema = initGlyphSchema();
			var arcSchema:DataSchema = initArcSchema();
			
			var glyphs:XMLList = sbgnML.elements("map")..glyph;
			var arcs:XMLList = sbgnML.elements("map").elements("arc");	
			
			
			//parse glyphs
			for each (var glyph:XML in glyphs) 
