Refactored #to_dcm methods of Image classes

Refactored the DICOM conversion methods of the Image classes with a more
DRY implementation.

Improved test coverage of the #to_dcm methods.

These changes affected the Image, ProjectionImage and SliceImage
classes.