How to export transient texture to disk?

Since version 4.21 the engine does not support anymore the function SaveImage of the class HighResScreenshotConfig, thus from my understanding I now have to use ExportToDisk from the UImageWriteBlueprintLibrary class. The problem is that it always fails to produce an image, since it fails the check


due to the field being null for the transient texture supplied in input, thus quitting the saving process. What am I doing wrong about this texture? The process by which I’m defining it is this

//OutBPM is an array of FColor filled in the beginning

UTexture2D* Texture = UTexture2D::CreateTransient(width, height, PF_B8G8R8A8);
FColor* MipData = static_cast<FColor*>(Texture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE));
FColor * Data = Mip.BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(MipData, OutBMP.GetData(), (width * height * 4));