moving bmp.unlock to its correct scope
implementing support for tile rotation/flip.

this code can be very optimized through math.
bugfix: moving variable to its correct scope

this is due if a img has alpha, the bmp need to be cleared.
removing duplicated line
Merge pull request #124 from ofabricio/master

gave it a quick read, can't test it for myself, so I'll trust you on this one :D