def write
      # Check if we are able to create given file:
      open_file(@file_name)
      # Go ahead and write if the file was opened successfully:
      if @file
        # Initiate necessary variables:
        init_variables
        @file_endian = false
        # Create a Stream instance to handle the encoding of content to a binary string:
        @stream = Stream.new(nil, @file_endian)
        # Tell the Stream instance which file to write to:
        @stream.set_file(@file)

        # Write Header and Image
        write_basic_header
        write_extended_header
        write_image

        # As file has been written successfully, it can be closed.
        @file.close
        # Mark this write session as successful:
        @success = true
      end

    end
def write
      # Check if we are able to create given file:
      open_file(@file_name)
      # Go ahead and write if the file was opened successfully:
      if @file
        # Initiate necessary variables:
        init_variables
        @file_endian = false
        # Create a Stream instance to handle the encoding of content to a binary string:
        @stream = Stream.new(nil, @file_endian)
        # Tell the Stream instance which file to write to:
        @stream.set_file(@file)

        # Write Header and Image
        write_basic_header
        write_extended_header
        write_image

        # As file has been written successfully, it can be closed.
        @file.close
        # Mark this write session as successful:
        @success = true
      end

    end
Creates an NWrite instance.

 === Parameters

 * <tt>obj</tt> -- A NObject instance which will be used to encode a NIfTI string.
 * <tt>file_name</tt> -- A string, either specifying the path of a DICOM file to be loaded, or a binary DICOM string to be parsed.
 * <tt>options</tt> -- A hash of parameters.

 === Options

 Handles the encoding of NIfTI information to string as well as writing it to file.