I prefer to use the function getimagesize(). You can test the image type regardingless of the extention..
list($width, $height, $type, $attr) = getimagesize($_FILES['userfile']['tmp_name']);
if ($_FILES['userfile']['size']<500001 && ($type == 2 || $type == 1)) {
// move_uploaded_file(etc etc etc etc.....
}