This is how to create a save dialog using C#. I am uisng C# becuase it is not possible with JavaScript. You do not need to open it in a new window. The browser will handle the response. So just creat a new page that you pass the file name and path to and the code does the rest.
String FileName = fileName + ".jpg"; //change
String FilePath = "\\global\\img\\temp\\"; //change
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
response.TransmitFile(FilePath + FileName);
response.Flush();
response.End();