Como converter fotos de perfil de usuários do microsoft graph 365 de dados binários em um formato de imagem legível

Exibi com sucesso informações sobre perfis de usuários administrativos Fotos usando a API do Microsoft Graph em PHP, abaixo está o código que usei

<?php
session_start();
echo $acc = $_SESSION['access_token'];
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://graph.microsoft.com/v1.0/me/photo/$value",
    CURLOPT_HEADER => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_HTTPHEADER => array(
        "authorization: Bearer $acc",
        "accept: application/json",
        "content-type: application/json; charset=utf-8"
    ) ,
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$res = json_decode($response);
$res1 = json_decode($response, true);
$res1['@odata.context'];
echo 'photo <img src="data:image/jpeg;base64,' . base64_encode($res1['@odata.context']) . '"/>';
echo '<p>photo Name : ' . $res1['@odata.context'] . '</p> 
      <img src="' . $res1['@odata.context'] . '"><br />';
echo '<pre>' . print_r($response, true) . '</pre>';

if ($err)
{
    echo "cURL Error #:" . $err;
}
else
{
}
?>

O cabeçalho retornou com uma chamada bem-sucedida:

HTTP/1.1 200 OK
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
request-id: dc3a8a0c-0ff1-455f-afe8-5cdeb6b70a1b
client-request-id: dc3a8a0c-0ff1-455f-afe8-5cdeb6b70a1b
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"North Central US","Slice":"SliceA","Ring":"3","ScaleUnit":"002","Host":"AGSFE_IN_14","ADSiteName":"CHI"}}
OData-Version: 4.0
Duration: 121.1991
Date: Sun, 03 Dec 2017 10:21:55 GMT

JSON retornou:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('2b7f8bf2-3d23-43e6-b068-39aa5009fed7')/photo/$entity",
    "@odata.mediaContentType": "image/jpeg",
    "@odata.mediaEtag": "\"10F9EA34\"",
    "id": "504X504",
    "height": 504,
    "width": 504
}

Meu problema é que, quando tentei exibir a imagem em um link de imagem no php conforme o resultado do json Curl no php, ele mostra a imagem.

Como faço para converter os dados binários da imagem retornada no formato legível da imagem do navegador

Below is the new error message after implementing Marc Solutions

CURLOPT_HTTPHEADER => array(
    "authorization: Bearer $acc",
    "accept: image/jpeg",
    "content-type: application/json; charset=utf-8"

)



HTTP/1.1 400 Bad Request
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/json
request-id: 93186bcd-05ad-41b5-bafe-8f5c4d7a3952
client-request-id: 93186bcd-05ad-41b5-bafe-8f5c4d7a3952
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"North Central US","Slice":"SliceA","Ring":"3","ScaleUnit":"001","Host":"AGSFE_IN_14","ADSiteName":"CHI"}}
OData-Version: 4.0
Duration: 104.1582
Date: Sun, 03 Dec 2017 16:09:14 GMT

{
  "error": {
    "code": "BadRequest",
    "message": "A supported MIME type could not be found that matches the acceptable MIME types for the request. The supported type(s) 'application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false, application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=true, application/json;odata.metadata=minimal;odata.streaming=true, application/json;odata.metadata=minimal;odata.streaming=false;IEEE754Compatible=false, application/json;odata.metadata=minimal;odata.streaming=false;IEEE754Compatible=true, application/json;odata.metadata=minimal;odata.streaming=false, application/json;odata.metadata=minimal;IEEE754Compatible=false, application/json;odata.metadata=minimal;IEEE754Compatible=true, application/json;odata.metadata=minimal, application/json;odata.metadata=full;odata.streaming=true;IEEE754Compatible=false, application/json;odata.metadata=full;odata.streaming=true;IEEE754Compatible=true, application/json;odata.metadata=full;odata.streaming=true, application/json;odata.metadata=full;odata.streaming=false;IEEE754Compatible=false, application/json;odata.metadata=full;odata.streaming=false;IEEE754Compatib...' do not match any of the acceptable MIME types 'image/jpeg'.",
    "innerError": {
      "request-id": "93186bcd-05ad-41b5-bafe-8f5c4d7a3952",
      "date": "2017-12-03T16:09:14"
    }
  }
}

questionAnswers(2)

yourAnswerToTheQuestion