Add write deadline as well

Also correctly handle errors that can occur when setting a deadline.