Its step 3 that is the issue. The XML data isn't the same as the XFA field properties (of which .rawValue is one)
When you created your form, you also created an XML data structure. If you don't manually bind sample XML or a schema to the form then Designer will create a default one for you. The default one will follow the same structure of your form, but it will not include the field properties - its just the data.
Note: If you are bound your form to a schema or sample XML then it will use that structure rather than the default.
The easiest way to see what it looks like is to open the form in Desinger.
Choose File, Form Properties.
Click on the Preview tab.
Click on the Generate Preview Data button.
Set the file name and location
This will save a sample XML file with jiberish standing in for real data. This is the XML format that you will need to use to insert the base64 data into the field.
One thing to keep in mind is that you are replacing ALL of the data when you do this type of re-render. If your form already has data, you will need to extract it (using Process Form Submission) and modify the resulting XML before re-rendering the form.
This is really more of a Form/Designer question then a Generator question, but I'll do my best to help out:
I'm assuming that you don't just want the default functionality of an image field (where the user clicks on the field and then browses to the image). Do you want to do this from the form itself (no server side rendering), or are you adding the image as part of a server side rendering of the form?
If its in the PDF itself you'll need to make a call to get the image data (such as a web service call), then add it to the image field using some script. Since you are making a service call and (presumably) saving the form afterwards, you'll need to add Reader Extensions to the document.
If you are doing it server side, as part of a process, then you will have to do the following:
Read the image into a document variable using the "Read Document" operation
Convert the image to base64 using a setValue operation and the Document Object Functions "getDocContentBase64" function
move the resulting base64 string into the proper place in an XML object (one that matches the form's data)
use either Forms, Output or Form Data Integration to render the form with the new data (that includes the image)