fix sanitize error -- review request #39

1. use WELS_CLIP1 to replace table look-up;
2. fix bugs about buffer overflow
3. add more boundary checks