better error messages
fix wrong error if 0 bytes are written - fix #64