added dynamic file encoding