added support(optional) in toLocalfile to change extensuions