Imagick image can not be converted to string on HHVM

made it consistent with the GD function.

See also https://github.com/yiisoft/yii/pull/3406