Encode file