Fixes #2 and #3 - converting to binary and writing to file.