you could try to read a existing jpg file,
( and also show it
https://processing.org/reference/loadImage_.html
)
but use:
https://processing.org/reference/loadBytes_.html
change bytes at positions what are outside the file definition area
and use:
https://processing.org/reference/saveBytes_.html
to save it back.
that could be a start??