Fix bug where buffer was being deleted underneath async_write operation.

Fix bug where member function called from async callback without holding valid shared_ptr to class.