resolve crashes due to use after free, switch to BIO_read

* Will not fix 0.9.8 yet