Replace fcntl locking with django.core.files.locks

The fnctl lock APIs aren't available on all platforms. Luckily, django provides
a cross-platform file locking implementation which uses fcntl on unix-like
systems and win32 APIs for Windows.

Fixes bug 3367.
Merge branch 'release-0.8.x'