Fix writeChunked when using SSL

we should make an upstream pull request too