Lua plugin: Escape special characters when quoting strings

Now \, " and newlines are correctly escaped when quoting strings in
the Lua output. I hope that covers all cases.

Closes #437
Merge branch '0.9'