Just save your input to a file then look at that file and you will see if there are any text data headers, etc. That will tell you what you have to remove to get to the actual image data which should be several lines down in the file preceded by a textual length of the data. After that length value is the data you want

Like this:

Header Info
Header Info
Header Info
etc

12345 '<-----length
ÿØÿàŸÏйàCzáGéR‰ˆã¿øR‚¬@#kvÇA@[|ño}6)ËkmæÜEµº|ƒ '<---- image data