Line 151 contains a bug:
// if metadata is too large, drop the thumbnail.
if (plaintext.length > 65535) {
var temp = JSON.parse(JSON.stringify(metadata));
delete metadata.thumbnail; // BUG!! this should read "delete **temp**.thumbnail", otherwise this is a NOP
plaintext = Nacl.util.decodeUTF8(JSON.stringify(temp));
}