writeFile method for cross domain