I strongly recommend to use the default Mendix functionality. You have enough functionality to do what you want. The runtime will ensure that all objects and filesystem attributes will be handled in the correct way. I strongly recommend not to edit the System.FileDocument 'manually' using Java.
So,
In case you want to replace the file associated with the System.Image object (instead of replacing the whole System.Image object), you have to use a Java action.
Core.storeFileDocumentContent(IContext context, IMendixObject fileDocument, java.io.InputStream inputStream)
.Core.getFileDocumentContent(IMendixObject fileDocument)
with that System.Image object as input to get the InputStream representing the image. This InputStream can be but in the inputStream param of the storeFileDocument call described above.You can do it in this simple way:
Because the latest object have no content the default image will be shown by (for example) the image viewer widget.
If you don't want to remove the System.Image instance and create a new one System.Image instance, but only change the existing System.Image instance, you'll need JAVA code. With JAVA code the related file can be deleted from the file system. Furthermore you have to reset some attributes out the System.FileDocument object (FileName, Size, e.t.c.), but that can also be done with microflow.
Would simply adding a boolean 'is default image' do the trick (so that you can retrieve the image by Xpath)?