Handle digest values of string or buffer

In nodejs 0.8.x, hash.digest() returns a string. In 0.10.x, it returns
a Buffer.

output.write() was throwing a type error when a buffer was provided.
I've put in some switcheroo code that checks the type of the digest
and uses the correct buffer-writing code.