Fixed crash in fs.write

Fixes #56