Lossless editing and resaving of JPEG photos