To have custom names for downloaded file use Content Disposition header (HTTP).
Also it is necessary to set the response headers before writing data to the response.
Otherwise the response headers will not have any effect.