--Added the ability to write metadata
--Fixed writing of character variables