code: void saveFSImage(SaveNamespaceContext context, ImageManager im, boolean forceUncompressed)
        throws IOException {
      
      long txid = context.getTxId();
      OutputStream os = im.getCheckpointOutputStream(txid);
  
      FSImageFormat.Saver saver = new FSImageFormat.Saver(context);
      FSImageCompression compression = FSImageCompression.createCompression(conf, forceUncompressed);
      
      saver.save(os, compression, null, im.toString());
      
      InjectionHandler.processEvent(InjectionEvent.FSIMAGE_SAVED_IMAGE, txid);
      storage.setCheckpointImageDigest(txid, saver.getSavedDigest());
    }
docs: Save the contents of the FS image to the file.