image/jpeg: encode *image.Gray as grayscale JPEGs.

Fixes issue 8201.

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://codereview.appspot.com/105990046

Committer: Nigel Tao <nigeltao@golang.org>
strings: reduce allocation in byteStringReplacer.WriteString

Use WriteString instead of allocating a byte slice as a
buffer. This was a TODO.

benchmark               old ns/op    new ns/op    delta
BenchmarkWriteString        40139        19991  -50.20%

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://codereview.appspot.com/107190044
encoding/base64, encoding/base32: speed up Encode
Avoid unnecessary bitwise-OR operations.

benchmark                      old MB/s     new MB/s  speedup
BenchmarkEncodeToStringBase64  179.02       205.74    1.15x
BenchmarkEncodeToStringBase32  155.86       167.82    1.08x

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://codereview.appspot.com/109090043