Since it takes some quirks to make this work, i thought i'd post a 5 liner to show how to add pictures on the fly with managed code.
In my example it was file attachments that needed to be converted to pictures for print view, but it could as well be a dropdown with with images in a Picture Library, folder or database, where you want to show the selected picture when selection changes.
IXMLDOMNode picture = yourNodeList.selectSingleNode("my:picture");//this is where you want to put your picture. Could be a repeating list with a dummy picture object
byte[] bytes = yourBinaryPicture;//this is a byte array containing the picture in binary format
if ( ((IXMLDOMElement)picture).getAttribute("xsi:nil") != null )
((IXMLDOMElement)picture).removeAttribute("xsi:nil");//remove attribute that specifies that the field has no value
picture.nodeTypedValue = Convert.ToBase64String(yourBinaryPicture);//convert byte array to a Base64 encoded string and insert into nodeTypedValue property
hope this saves some head scratching for someone :-)