Index: wp-includes/class-wp-image-editor.php
===================================================================
--- wp-includes/class-wp-image-editor.php	(revision 24502)
+++ wp-includes/class-wp-image-editor.php	(working copy)
@@ -327,13 +327,11 @@
 	 * @return boolean
 	 */
 	protected function make_image( $filename, $function, $arguments ) {
-		$dst_file = $filename;
-
 		// The directory containing the original file may no longer exist when using a replication plugin.
-		wp_mkdir_p( dirname( $dst_file ) );
+		wp_mkdir_p( dirname( $filename ) );
 
 		if ( $stream = wp_is_stream( $filename ) ) {
-			$filename = null;
+			$arguments[1] = null;
 			ob_start();
 		}
 
@@ -342,7 +340,7 @@
 		if ( $result && $stream ) {
 			$contents = ob_get_contents();
 
-			$fp = fopen( $dst_file, 'w' );
+			$fp = fopen( $filename, 'w' );
 
 			if ( ! $fp )
 				return false;
