Add encoding option for when writing file for --code.