I am reading the media file from under the 'media library' (Sitecore 9.3) and processing the image through kraken.io/

Then I am updating the media item in Sitecore with this processed image.

Code snippet for updating the image:

var options = new MediaCreatorOptions
    FileBased = false,
    IncludeExtensionInItemName = false,
    Versioned = false,
    Destination = imagePathInSitecore,
    Database = Sitecore.Configuration.Factory.GetDatabase(Constants.MasterDatabase),
    AlternateText = itemAsMediaItem.Alt,

var creator = new MediaCreator();
var mediaItem = creator.AttachStreamToMediaItem(GetStreamFromUrl(optimizedImageURL), imagePathInSitecore, item.Paths.Path + item.Name + itemAsMediaItem.Extension, options);

But we are noticing that the template is getting changed from Unversioned/Image to Unversioned/File

Any guidance?