Postgresql 9.1, PHP 5.3.8, lighttpd 1.4.29, Suse 11.4 x64.

I'm trying to insert image converted with imagick to bytea field.
PHP Code:
$this->_thumbnail base64_encode($imagick); 
# Save to Postgresql
Some images work but others give me errors.

From lighttpd log:
2011-10-27 20:39:02: (mod_fastcgi.c.2566) unexpected end-of-file (perhaps the fastcgi process died): pid: 0 socket: unix:/srv/.../x.socket 
2011-10-27 20:39:02: (mod_fastcgi.c.3354) response not received, request sent: 45894 on socket: unix:/srv/.../x.socket for /index.php?, closing connection 

Oct 27 20:39:03 linux kernel: [33328.101710] php-cgi[17873]: segfault at 7fffa8fbbf48 ip 00007fd590910ff6 sp 00007fffa8fbbf00 error 6 in[7fd590900000+35000]
Oct 27 20:39:03 linux postgres[29093]: [5-1] 2011-10-27 20:39:03 CEST x x LOG:  unexpected EOF in client connection
Do You have some idea what can cause a problem?