Improve performance of URLOutputStream. Closes #654.