Write encoded file