added possibility to specify the encoding