Updated Answer
In fact, you can put the JPEG image on the clipboard using Applescript, like this on the command line:
osascript -e 'set the clipboard to (read (POSIX file "/Users/mark/Desktop/a.jpg") as JPEG picture)'
Then you can check what is on the clipboard:
osascript -e 'clipboard info' JPEG picture, 175960, «class 8BPS», 641904, GIF picture, 124637, «class jp2 », 102086, TIFF picture, 1481282, «class PNGf», 412940, «class BMP », 1477734, «class TPIC», 609835
And also insert the image into the document with the usual ⌘ -V.
Original answer
You can do this without having to compile any additional software and just use the tools provided in OS X. Basically, the clipboard cannot store binary files, so uuencode your binary image into plain ASCII data like this
and uudecode on the return trip
source share