If one do:
file->SetWriteModeToRGB()
then call
file->Write( filename )
the file will be refused to be written (function will return false).
Fix:
Explicitely set the Sample Per Pixel to be 3.
header->InsertValEntry("3",0x0028,0x0002); // Samples per Pixel
HTH,
Mathieu