 							case ResponseType.UINT8ARRAY:
 								return resolve(byteArray);
 							case ResponseType.DATAURI:
-								return resolve("data:" + (urlRequest.mimeType || '') + ';base64,' + JS.global.btoa(byteArray));
+								return resolve(byteArrayToDataUri(byteArray, urlRequest.mimeType));
 						}
 					});
 				});

						
						if (urlRequest.responseType === ResponseType.UINT8ARRAY)
							result = new JS.Uint8Array(result);
						
						resolve(result);
						done = true;

					for (var name:String in urlRequest.requestHeaders)
						xhr.setRequestHeader(name, urlRequest.requestHeaders[name], false);
					
					if (urlRequest.responseType === ResponseType.UINT8ARRAY || urlRequest.responseType === ResponseType.DATAURI)
						xhr.responseType = ResponseType.ARRAYBUFFER;
					else
						xhr.responseType = urlRequest.responseType;
