mitk::ImageWriter has two methods SetExtension(), one with const char* as parameter, one with std::string as parameter.
The std::string version overwrites the filename (instead of the extension, as should be expected):
void mitk::ImageWriter::SetExtension(const std::string & extension)
{
this->SetFileName( extension.c_str() );
}
Instead, the method should probably look like this:
void mitk::ImageWriter::SetExtension(const std::string & extension)
{
this->SetExtension( extension.c_str() );
}