writing jpg processing subroutine