added option to pass in image data directly