How to convert string to bytearray?

Wireshark supports Lua and I’m using Lua.
There is an Lua API: dumper:dump(timestamp, pseudoheader, bytearray)
which can write bytearray into a file.
Now I can do so. For example, I have succeeded in writing bytearry “41 41 41” in to a file. When I open the file with notepad, I read “AAA”. In fact, 41 is ASCII of ‘A’.
But, I want to write a string. How to convert a string to bytearrary?
Thanks!