encode javascript string, fixes #94