Your addition of the origin image is not consistent with the origin. Instead of correcting for the position in absolute coordinates here, I think we should leave the original lines from the MSD code.

Then, in the function that builds the snapshot, make the snapshot image be the particle image minus the origin image. That way, the need to make corrections is all hidden in the snapshot build function and we don't need to sprinkle them all over HOOMD (i.e. the DCD writer).

After all, the issue is that the grid shift is artificially increasing the image flags, so the snapshot should not have that in it.