save base64 images alogside entity creation
It works after getting file mime type here is the code sample

$data = base64_decode($args[1]['avatar']);    
$finfo = finfo_open();
        $mime_type = finfo_buffer($finfo, $data, FILEINFO_MIME_TYPE);
        finfo_close($finfo);
        // get file type png. jpg
        $ext = $mime_type ? str_replace('image/', '', $mime_type) : 'png';
        $file_name = str_replace(' ', '-', $args[1]['name']);


then you we save the file using 

$file = file_save_data($data, 'public://users/'.$file_name.'.'.$ext, FILE_EXISTS_REPLACE);

    $args[1]['field_field_user_picture'] = array(
        'fid' =&gt; $file-&gt;fid,
        'width' =&gt; 100,
        'height' =&gt; 100,
        'alt' =&gt; $args[1]['name'],
        'title' =&gt; $args[1]['name']
    );