fixed encoding issues when using formatted option