Added casts to the write calls

The IDE wouldn't compile otherwise...