How do I return an image from a script

Fatal error: Call to undefined function __() in
/homepages/5/d367772185/htdocs/rodandfly/wp-admin/includes/file.php on
line 13

Where is your code? file.php is expecting __() to be defined which it should be if your loading it from within an activated plugin.

The best way to do what your trying to do is use either media_handle_sidelaod() or media_sideload_image() which will cause WordPress to create the thumbnails from the full image.

$resized_img_url = wpse_download_resize( 'http://www.linux.org/images/logo/linuxorg.gif' );

function wpse_download_resize( $url ) {
    $tmp = download_url( $url );
    $file = array(
        'name' => basename( $url ),
        'tmp_name' => $tmp
    );

    if ( is_wp_error( $tmp ) ) {
        @unlink( $file[ 'tmp_name' ] );
    return $tmp
    }

    $id = media_handle_sideload( $file, 0 );
    // Check for handle sideload errors.
    if ( is_wp_error( $id ) ) {
        @unlink( $file['tmp_name'] );
    return $id;
    }

    return wp_get_attachment_thumb_url( $id );
}