Fixed rotate method to match the documentation.

Also used scratchbuf in the filter methods.