Missed this TODO in comment below.  Looks like you need to convert the outputstream to an inputstream that can be put in the response.  Look at ThumbnailResource for how the inputstream is used, the best bet on first part is probably a ByteArray copy.