Covert to RGB?

Hey all,
I’m stuck with this php script.
I have the following:

<?php
if($submit){
$target = "uploads/memberspics/";
$pic = $target . ereg_replace('[^a-z0-9A-Z.]','',$username) . '.' . jpg;
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $pic);
}
fopen("$pic", "a+");
$im = imageCreateFromJPEG($pic);
imageInterlace($pic,0);
$width = imageSX($im);
$height= imageSY($im);
$n_width =250;  
$n_height = 250; 
$newimage = ImageCreateTrueColor("$n_width","$n_height");				 
ImageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$pic ,75);
chmod("$pic",0777);
fclose($pic);
fopen("$pic", "r");
$target_path = "uploads/memberspics/thumbnails/";
$im = imageCreateFromJPEG($pic);
imageInterlace($pic,0);
$width = imageSX($im);
$height= imageSY($im);
$n_width =100;  
$n_height = 100; 
$newimage = ImageCreateTrueColor("$n_width","$n_height");				 
ImageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$target_path . ereg_replace('[^a-z0-9A-Z.]','',$username) . '.' . jpg,75);
chmod("$pic",0777);
fclose($pic);
?>

really simple script and when it works, it works well…however, with alot of pics i am having the following problem:

imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error

i check it out on the php website and they said it was because the pics have to be in RGB format to convert! Is there a way around this?
Thanks everyone!