Kohana中的imagestring函数

i have a little problem with creating an image and writing a text on it in Kohana. My code works fine if i use a simple php, but i can't integrat it in Kohana framework controller and action. when i am doing that in action it retruns me a strange code which i think could be a image bitecode

in my action i have put the headers for image like this

$this->request->headers['Content-Type'] = 'image/jpeg';

and then i am coding for simple image creation

$image = imagecreate(450,250);
$color = imagecolorallocate($image,0,0,0);
imagestrig($image,5,34,56,"some txt",$color);
imagejpeg($image,NULL,100);

and i am going to this action with this routing url - constructor(controller)/image_creator(action) it returns me blabla bla a strange unicode text

does anyone know how to actually create image whit this framework: i have tried like this, but it also doesn't work: http://forum.kohanaframework.org/discussion/4412/solved-ko3-gd-and-htmlimage/p1

Actually i am not trying to display it, i don't need to show created image, i want to create image, and then send it to mail, but my script doesn't work, how can i get image in actin and mail it?

The easiest way is to save this image and then attach to email.

// ...
$imagePath = 'tmp/'.time().uniqid().'.jpg';
imagejpeg($im, $imagePath);

// Attach created image to email (let's assume you're using Swift Mailer)
$m->attach(Swift_Attachment::fromPath($imagePath)->setDisposition('inline'));
// ...send email    

imagedestroy($im);
// Remove image from hard disk
unlink($imagePath);