Fix encoding bug caused by PR #80

Francisco,

Here's the fix for the bug mentioned in PR #77.

-Glen.