Make sure to UTF-8 encode Document and fix ahuth/emcee#32

Fixes encoding issues in JavaScript files (ahuth/emcee#32)