fix possible array underflow

there are multiple issues with this code

- php_stream_read() returns an unsigned val, so is >= 0
- if it read less than sizeof(a) bytes, the function operates on garbage
- result->channels is an unsigned val, so >= 0
Merge branch 'PHP-5.5' into PHP-5.6

* PHP-5.5:
  fix possible array underflow
Merge branch 'PHP-5.6'

* PHP-5.6:
  fix possible array underflow

Conflicts:
	ext/standard/image.c