Made idetools.IOManager.write() more robust.