Cómo convertir fotos de perfil de usuarios de microsoft graph 365 de datos binarios a un formato de imagen legible

He mostrado con éxito información sobre los perfiles de los usuarios administradores Fotos usando la API de Microsoft Graph en PHP, a continuación se muestra el código que usé

<?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
{
}
?>

Encabezado devuelto con una llamada exitosa:

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 regresó:

{
    "@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
}

MI problema es que cuando traté de mostrar la imagen en un enlace de imagen en php según el resultado de json Curl en php, sí muestra la imagen.

¿Cómo convierto los datos de imagen devueltos binarios a formato legible de imagen del 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"
    }
  }
}

Respuestas a la pregunta(2)

Su respuesta a la pregunta