How to populate nodes with imagefield programmatically?
I don't have the exact answer to your question, but you could check how other modules do it. Devel Generate for instance (part of Devel) can populate image fields. Check out devel_generate_fields() in devel_generate.fields.inc and image_devel_generate() in image.devel_generate.inc.

Hope that helps.