The image breaks on sub-sites in a directory, should be able to use theme('image', array('path' => "islandora/object/$pid/datastream/JPG/view" ...)