provide encodeAsJPEG functionality